import { ref } from "vue";

export default function myPagination(
    paginationCurrentChange:any,
    paginationSizeChange:any
) {
  // 定义在use函数中，而不是外部，因为我们希望每次调用usePagination函数的时候，这些值都进行初始化
  const total = ref(0);
  const page = ref(1);
  const pageSize = ref(5);

  //监听当前页的变化
  const paginationCurrentChangeListener = (v:number)=>{
    page.value = v;
    paginationCurrentChange()
  }
  //监听每页条数的变化
  const paginationSizeChangeListener = (v:number)=>{
    pageSize.value = v;
    paginationSizeChange()
  }

  return{
    total,
    page,
    pageSize,
    paginationCurrentChangeListener,
    paginationSizeChangeListener
  }
}
